package com.lichongbing.lyoggl.mapper;

import com.lichongbing.lyoggl.model.TimeEntries;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Entity com.lichongbing.lyoggl.model.TimeEntries
 */
@Component
public interface TimeEntriesMapper extends BaseMapper<TimeEntries> {

    @Update("update time_entries  set stop = #{start}, duration= #{duration} where id= #{timeEntrieid}")
    boolean updateDurationById(String start, long duration,String timeEntrieid);


    @Select("select t.id,t.pid,p.name,t.description,t.start,t.duration,t.tid,g.name as tags1,g.r,g.g,g.b from  time_entries t left join project p  on p.id = t.pid left join tags g on g.id = t.tid   where t.uid = #{userid}  and t.start > #{start} and t.stop < #{end} order by t.start asc")
    List<TimeEntries> getTodayTimeEntries(String userid,String start, String end );
}




